{template 'public/header'}

{template 'public/comhead'}

<link rel="stylesheet" type="text/css" href="../addons/yzzc_sun/template/public/ygcsslist.css">
<ul class="nav nav-tabs">
    <span class="ygxian"></span>
    <div class="ygdangq">当前位置:</div>
    <li  {if $type=='all'} class="active" {/if}><a href="{php echo $this->createWebUrl('goods',array('type'=>all));}">全部车型</a></li>
    <li   {if $type=='wait'} class="active" {/if}><a href="{php echo $this->createWebUrl('goods',array('type'=>wait,'status'=>1,'storename'=>$storename,'keywords'=>$op));}">已上架</a></li>
    <li   {if $type=='ok'} class="active" {/if}><a href="{php echo $this->createWebUrl('goods',array('type'=>ok,'status'=>2,'storename'=>$storename,'keywords'=>$op));}">已出租</a></li>
    <li   {if $type=='no'} class="active" {/if}><a href="{php echo $this->createWebUrl('goods',array('type'=>no,'status'=>3,'storename'=>$storename,'keywords'=>$op));}">已下架</a></li>

</ul>
<div class="row ygrow">
    <div class="col-lg-12">
        <form action="" method="get" class="col-md-4">
            <input type="hidden" name="c" value="site" />
            <input type="hidden" name="a" value="entry" />
            <input type="hidden" name="m" value="yzzc_sun" />
            <input type="hidden" name="do" value="goods" />
            <input type="hidden" name="storename" value="{$storename}" />
            <input type="hidden" name="status" value="{$status}" />
            <input type="hidden" name="type" value="{$type}" />
            <div class="input-group">
                <input type="text" name="keywords" class="form-control" placeholder="请输入车辆名称" value='{$op}'>
                <span class="input-group-btn">
                    <input type="submit" class="btn btn-default" name="submit" value="查找"/>
                </span>
            </div>
            <input type="hidden" name="token" value="{$_W['token']}"/>
        </form>

        <div class="col-md-4">
            <input type="hidden" name="token" value="{$_W['token']}"/>
        </div>
    </div><!-- /.col-lg-6 -->
</div>
<div class="row ygrow">
    <div class="col-lg-12">
        <form action="" method="get" class="col-md-4">
            <input type="hidden" name="c" value="site" />
            <input type="hidden" name="a" value="entry" />
            <input type="hidden" name="m" value="yzzc_sun" />
            <input type="hidden" name="do" value="goods" />
            <input type="hidden" name="keywords" value="{$op}" />
            <input type="hidden" name="status" value="{$status}" />
            <input type="hidden" name="type" value="{$type}" />

            <div class="input-group">
                <input type="text" name="storename" class="form-control" placeholder="请输入门店名称" value='{$storename}'>
                <span class="input-group-btn">
                    <input type="submit" class="btn btn-default" name="submit" value="查找"/>
                </span>
            </div>
            <input type="hidden" name="token" value="{$_W['token']}"/>
        </form>

        <div class="col-md-4">
            <input type="hidden" name="token" value="{$_W['token']}"/>
        </div>
    </div><!-- /.col-lg-6 -->
</div>
{if empty($ordertime)}
<div class="row ygrow">
    <div class='col-lg-12'>
        <a data-toggle="modal" data-target="#myModalsss"><button class="btn btn-xs storeblue">一键同步占用时间</button></a>
        <div class="modal fade" id="myModalsss" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
          <div class="modal-dialog" role="document">
                <div class="modal-content">
                  <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel" style="font-size: 20px;">一键同步占用时间</h4>
                  </div>
                  <form action="" method="get" >
                      <input type="hidden" name="c" value="site" />
                      <input type="hidden" name="a" value="entry" />
                      <input type="hidden" name="m" value="yzzc_sun" />
                      <input type="hidden" name="do" value="goods" />
                      <input type="hidden" name="op" value="add" />
                      <div class="modal-body" style="font-size: 20px">
                            <span>是否将订单内的所有已被选时间同步到占用时间中？</span>
                      </div>

                      <div class="modal-footer">
                          <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                          <input type="submit" class="btn btn-info" name="submit" value="确定"/>
                      </div>
                      <input type="hidden" name="token" value="{$_W['token']}"/>
                  </form>
                </div>
              </div>
          </div>
    </div>
</div>
{/if}
<div class="main">
    <!--<div class="panel panel-default">-->
        <!--<div class="panel-body ygbtn">-->
            <!--<div class="btn ygshouqian2" id="allselect">批量删除</div>-->
            <!--<div class="btn ygyouhui2" id="allpass">批量通过</div>-->
            <!--<div class="btn storegrey2" id="allrefuse">批量拒绝</div>-->
        <!--</div>-->
    <!--</div>-->
    <div class="panel panel-default">
        <div class="panel-heading">
            车辆列表
        </div>
        <div class="panel-body" style="padding: 0px 15px;">
            <div class="row">
                <table class="yg5_tabel col-md-12">
                    <tr class="yg5_tr1">
                        <!--<td class="store_td1 col-md-1" style="text-align: center;">-->
                            <!--<input type="checkbox" class="allcheck" />-->
                            <!--<span class="store_inp">全选</span>-->
                        <!--</td>-->
                        <td class="col-md-1">编号</td>
                        <td class="col-md-1">车辆名称</td>
                        <td class="col-md-1">所属门店</td>
                        <td class="col-md-1">车牌号</td>
                        <td class="col-md-1">颜色/车身结构/排量/变速箱/核载人数</td>
                        <td class="col-md-1">租金（日租价）</td>
                        <td class="col-md-1">押金</td>
                        <td class="col-md-1">手续费</td>
                        <td class="col-md-1">基础服务费</td>
                        <td class="col-md-1">尊享服务费</td>
                        <td class="col-md-1">是否推荐到首页</td>
                        <td class="col-md-1">是否设为热门车型</td>
                        <td class="col-md-1">状态</td>
                        <td class="col-md-2">操作</td>
                    </tr>
                    {loop $list $key $item}
                    <tr class="yg5_tr2">
                        <!--<td>-->
                            <!--<input type="checkbox" name="test" value="{$item['id']}">-->
                        <!--</td>-->
                        <td>{$item['id']}</td>
                        <td>{$item['name']}</td>
                        <td>{$item['storename']}</td>
                        <td>{$item['carnum']}</td>
                        <td>{$item['colour']} / {if $item['structure'] == 1}两厢
                            {elseif $item['structure'] == 2}三厢{/if} / {if $item['grarbox'] == 1}手动挡
                            {elseif $item['grarbox'] == 2}自动挡{/if} / {$item['displacement']} / {$item['num']}人</td>
                        <td>{$item['money']}</td>
                        <td>{$item['deposit']}</td>
                        <td>{$item['fee']}</td>
                        <td>{$item['service_fee']}</td>
                        <td>{$item['zx_service_fee']}</td>
                        <td>{if $item['rec'] == 1}已推荐至首页
                            {elseif $item['rec'] == 2}未推荐
                            {/if}</td>
                        <td>{if $item['hot'] == 1}是
                            {elseif $item['hot'] == 2}否
                            {/if}</td>
                        {if $item['status']==1}
                        <td>
                            <span class="label storered">已上架</span>
                        </td >
                        {elseif $item['status']==2}
                        <td >
                            <span class="label storeblue">已出租</span>
                        </td>
                        {elseif $item['status']==3}
                        <td >
                            <span class="label storeblue">已下架</span>
                        </td>
                        {/if}
                        <td>
                            
                            {if $item['rec']==1}
                            <a href="{php echo $this->createWebUrl('goods',array('op'=>'rec1','id'=>$item['id']));}"><button class="btn storeblue btn-xs">取消推荐</button></a>
                            {/if}
                            {if $item['rec']==2}
                            <a href="{php echo $this->createWebUrl('goods',array('op'=>'rec2','id'=>$item['id']));}"><button class="btn storered btn-xs">推荐至首页</button></a>
                            {/if}
                            {if $item['hot']==1}
                            <a href="{php echo $this->createWebUrl('goods',array('op'=>'hot1','id'=>$item['id']));}"><button class="btn storeblue btn-xs">取消热门</button></a>
                            {/if}
                            {if $item['hot']==2}
                            <a href="{php echo $this->createWebUrl('goods',array('op'=>'hot2','id'=>$item['id']));}"><button class="btn storered btn-xs">设为热门</button></a>
                            {/if}
                            {if $item['status']==1}
                            <a href="{php echo $this->createWebUrl('goods',array('op'=>'xj','id'=>$item['id']));}"><button class="btn storegrey btn-xs">下架</button></a>
                            {/if}
                            {if $item['status']==3}
                            <a href="{php echo $this->createWebUrl('goods',array('op'=>'sj','id'=>$item['id']));}"><button class="btn storegrey btn-xs">上架</button></a>
                            {/if}
                            <!-- {if $item['status']==2}
                            <a href="{php echo $this->createWebUrl('goods',array('op'=>'sj','id'=>$item['id']));}"><button class="btn storegrey btn-xs">还车</button></a>
                            {/if} -->
                            <a href="{php echo $this->createWebUrl('ordertime',array('carnum'=>$item['carnum']));}"><button class="btn storeblue btn-xs">出租时间</button></a>

                            <a href="{php echo $this->createWebUrl('goodsinfo',array('id'=>$item['id']));}" class="storespan btn btn-xs">
                                <span class="fa fa-pencil"></span>
                                <span class="bianji">编辑
                                    <span class="arrowdown"></span>
                                </span>
                            </a>
                            <a href="javascript:void(0);" class="storespan btn btn-xs" data-toggle="modal" data-target="#myModal{$item['id']}">
                                <span class="fa fa-trash-o"></span>
                                <span class="bianji">删除
                                    <span class="arrowdown"></span>
                                </span>
                            </a>

                            <!-- <a href="{php echo $this->createWebUrl('goodsinfo',array('id'=>$item['id']));}"><button class="btn btn-success btn-xs">查看</button></a>
                           <button type="button" class="btn btn-danger btn-xs" data-toggle="modal" data-target="#myModal{$item['id']}">删</button> -->
                        </td>
                    </tr>
                    <div class="modal fade" id="myModal{$item['id']}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                    <h4 class="modal-title" id="myModalLabel" style="font-size: 20px;">提示</h4>
                                </div>
                                <div class="modal-body" style="font-size: 20px">
                                    确定删除么？
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                    <a href="{php echo $this->createWebUrl('goods', array('op' => 'delete', 'id' => $item['id']))}" type="button" class="btn btn-info" >确定</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    {/loop}
                    {if empty($list)}
                    <tr class="yg5_tr2">
                        <td colspan="8">
                            暂无车辆信息
                        </td>
                    </tr>
                    {/if}
                </table>
            </div>
        </div>
    </div>
</div>
<div class="text-right we7-margin-top">
    {$pager}
</div>
<script type="text/javascript">
    $(function(){
        $("#frame-7").show();
        $("#yframe-7").addClass("wyactive");
        /*删除*/
        function del(id) {
            var ret = confirm("您确定删除吗？")
            if (ret==true){
                $.ajax({
                    type:"POST",
                    url:"/web/index.php?c=site&a=entry&op=delete&do=goods&op=delete&module_name=yzzc_sun&version_id=1",
                    dataType:"JSON",
                    data:{id:id},
                    success:function(res){
                        console.log(res);
                        location.reload();
                    }
                })
            }
        }
        // ———————————————批量删除———————————————
        $("#allselect").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要删除的商品!');
                return false;
            }else if(confirm("确认要删除此商品?")){
                var id = new Array();
                check.each(function(i){
                    id[i] = $(this).val();
                });

                $.ajax({
                    type:"post",
                    url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=DeleteGoods&m=yzzc_sun",
                    dataType:"text",
                    data:{id:id},
                    success:function(data){
                        console.log(data);
                        location.reload();
                    }
                })

            }
        });

        // ———————————————批量通过———————————————
        $("#allpass").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要通过的商品!');
                return false;
            }else if(confirm("确认要通过此商品?")){
                var id = new Array();
                check.each(function(i){
                    id[i] = $(this).val();
                });
                console.log(id)
                $.ajax({
                    type:"post",
                    url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=AdoptGoods&m=yzzc_sun",
                    dataType:"text",
                    data:{id:id},
                    success:function(data){
                        console.log(data);
                        location.reload();
                    }
                })
            }
        });

        // ———————————————批量拒绝———————————————
        $("#allrefuse").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要拒绝的商品!');
                return false;
            }else if(confirm("确认要拒绝此商品?")){
                var id = new Array();
                check.each(function(i){
                    id[i] = $(this).val();
                });
                console.log(id)
                $.ajax({
                    type:"post",
                    url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=RejectGoods&m=yzzc_sun",
                    dataType:"text",
                    data:{id:id},
                    success:function(data){
                        console.log(data);
                        location.reload();
                    }
                })
            }
        });

        $(".allcheck").on('click',function(){
            var checked = $(this).get(0).checked;
            $("input[type=checkbox]").prop("checked",checked);
        });
    })
</script>